import { EntitySchema } from '@mikro-orm/core';

export class TypechoComments {
  coid!: number;
  cid?: number = 0;
  created?: number = 0;
  author?: string;
  authorId?: number = 0;
  ownerId?: number = 0;
  mail?: string;
  url?: string;
  ip?: string;
  agent?: string;
  text?: string;
  type?: string;
  status?: string;
  parent?: number = 0;
}

export const TypechoCommentsSchema = new EntitySchema({
  class: TypechoComments,
  properties: {
    coid: { primary: true, type: 'number' },
    cid: { type: 'number', nullable: true, default: 0, index: 'cid' },
    created: { type: 'number', nullable: true, default: 0, index: 'created' },
    author: { type: 'string', length: 150, nullable: true },
    authorId: { type: 'number', fieldName: 'authorId', nullable: true, default: 0 },
    ownerId: { type: 'number', fieldName: 'ownerId', nullable: true, default: 0 },
    mail: { type: 'string', length: 150, nullable: true },
    url: { type: 'string', length: 255, nullable: true },
    ip: { type: 'string', length: 64, nullable: true },
    agent: { type: 'string', length: 520, nullable: true },
    text: { type: 'string', columnType: 'text', nullable: true },
    type: { type: 'string', length: 16, nullable: true, default: 'comment' },
    status: { type: 'string', length: 16, nullable: true, default: 'approved' },
    parent: { type: 'number', nullable: true, default: 0 },
  },
});
